﻿@model Kooboo.CMS.Sites.Models.Page
@{
    ViewBag.Title = ViewContext.RequestContext.GetRequestValue("title").Localize();
    Layout = "~/Views/Shared/Blank.cshtml";
}

@section Panel{
    <ul class="panel">
        <li>
            <a href="@Url.Action("Revert", ViewContext.RequestContext.AllRouteValues())" data-ajax="Post" data-confirm="@("Are you sure you want to revert to this version?".Localize())">
                @Html.IconImage("reset")  @("Revert".Localize())
            </a>
        </li>

        <li>
            <a href="@ViewContext.RequestContext.GetRequestValue("return")">
                @Html.IconImage("cancel") @("Back".Localize())
            </a>
        </li>
       
        @foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
        {
            @Html.Partial("_ToolbarGroupButtons", group)
        }
    </ul>
}
<div class="block common-form">

    <h1 class="title">
        @ViewBag.Title : <strong>@ViewContext.RequestContext.GetRequestValue("UUID") - @ViewContext.RequestContext.GetRequestValue("version")</strong>
    </h1>

    @using (Html.BeginForm("Edit", "Page", ViewContext.RequestContext.AllRouteValues(), FormMethod.Post, new RouteValueDictionary(new { id = "page-form" })))
    {
        @Html.Hidden("SiteName", ViewContext.RequestContext.GetRequestValue("SiteName"))
        @Html.Hidden("ParentPage", ViewContext.RequestContext.GetRequestValue("ParentPage"))
        @Html.Hidden("old_Key", Model.FullName)
        @Html.ValidationSummary(true)
        @Html.Partial("_PageTabs", Model, new ViewDataDictionary() { { "IsCreating", false } })
    }
</div>

<script type="text/javascript">
    $(function () {
        $('.tabs').koobooTab();

        var enableScript = $('#EnableScript').change(function () {
            var handler = $(this);
            if (!handler.attr('checked')) {
                enableJquery.attr('checked', false).attr('disabled', true);
            } else {
                enableJquery.removeAttr('disabled');
            }
        });

        var enableJquery = $('#EnableJquery').change(function () {
            var hanlder = $(this);
            if (hanlder.attr('checked')) {
                enableScript.attr('checked', true);
            }
        });

        if (!enableScript.attr('checked')) {
            enableJquery.attr('checked', false).attr('disabled', true);
        } else {
            enableJquery.removeAttr('disabled');
        }

    });

    function onSuccess(responseData) {
        if (responseData.Model && responseData.Model.preview == true) {
            $.pop({
                url: responseData.RedirectUrl,
                width: $(window).width() - 20,
                height: $(window).height() - 50,
                frameHeight: "100%",
                popupOnTop: true
            });
            return false;
        }
        return true;
    }


    $(function () {
        $('div.command').remove();

        $('#layout-edit').remove();

        $('a.o-icon.remove,a.o-icon.csharp,a.o-icon.design,a.o-icon.add').remove();

        $(':submit').remove();

        $('input,select').attr('disabled', true);

        window.pageDesignOnLoad(function () {
            $('#iframeMask').show().css('background', 'none');
        });

    });

</script>
